
class IDA2IDBMap:
    def __init__(self):
        self.IDMapDict = {}

    def __setitem__(self, key, value):
        self.Add(key, value)

    def __getitem__(self, key):
        ret = self.IDMapDict[key]
        return ret

    def Add(self, IDA, IDB):
        # IDA -> IDB
        self.IDMapDict[IDA] = IDB

    def HasIDA(self, IDA):
        ret = self.IDMapDict.has_key(IDA)
        return ret

    def IDAChange(self, oldIDA, newIDA):
        self.IDMapDict[newIDA] = self.IDMapDict.pop(oldIDA)

    def IDARemove(self, IDA):
        del self.IDMapDict[IDA]

    def IDAGet(self, IDB):
        for (_ida, _idb) in self.IDMapDict.items():
            if _idb == IDB:
                ret = _ida
                break
        else:
            ret = None
        return ret